package main

import "fmt"

func Array() {
	a1 := [3]int{9, 8, 7}
	fmt.Printf("a1: %v, len:%d, cap:%d \n", a1, len(a1), cap(a1))
	//len是长度，cap是容量，len是真的有几个元素，cap是可以放几个元素

	a2 := [3]int{9, 8, 7}
	fmt.Printf("a2: %v, len:%d, cap:%d \n", a2, len(a2), cap(a2))

	var a3 [3]int
	fmt.Printf("a3: %v, len:%d, cap:%d \n", a3, len(a3), cap(a3))

	//按下标来访问数据的方式，如果访问时超过下标编译报错
	fmt.Printf("a[1]: %d \n", a1[1])

}

//打印
//a1: [9 8 7], len:3, cap:3
//a2: [9 8 7], len:3, cap:3
//a3: [0 0 0], len:3, cap:3

func Arr1(idx int) {
	a1 := [3]int{9, 8, 7}
	fmt.Printf("a1[1]: %d \n", a1[idx])
}
